/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.itschapala.dsw2.biblioteca.dao;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import mx.itschapala.dsw2.biblioteca.enumeracion.EstadoDetallePrestamo;
import mx.itschapala.dsw2.biblioteca.modelo.DetallePrestamo;
import mx.itschapala.dsw2.biblioteca.modelo.Prestamo;


@Stateless
public class DetallePrestamoDao extends AbstractDao<DetallePrestamo> implements DetallePrestamoDaoLocal {
    @PersistenceContext(unitName = "biblioteca-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public DetallePrestamoDao() {
        super(DetallePrestamo.class);
    }

    @Override
    public List<DetallePrestamo> findLends(Prestamo lend) {
     Query q = em.createNamedQuery("DetallePrestamo.findLends");
     q.setParameter("estado", EstadoDetallePrestamo.LEND.ordinal());
     q.setParameter("idPrestamo", lend.getId());
     return q.getResultList();
    }
    
}
